package uk.ac.warwick.dcs.csufbo;

import javax.sound.midi.*;

import java.util.ArrayList;

/*
 * @deprecated
 */
public class LSysProcessor
{
	public LSysProcessor()
	{

	}

	private static FitnessTester mFitTest;

	public Sequence toSequence(LSys lSysToConv, int root, int maxLength,
			int numOfPasses)
	{
		Sequence midSeq = null;
		MidiEvent notething = null;
		ShortMessage message = new ShortMessage();
		ArrayList<Integer> returnedNoteList;

		returnedNoteList = lSysToConv.getOutputString(maxLength, numOfPasses);

		try
		{
			midSeq = new Sequence(Sequence.PPQ, 2, 1);
		}
		catch (InvalidMidiDataException e1)
		{
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		for (int i = 0; i < returnedNoteList.size(); i++)
		{
			try
			{
				message.setMessage(ShortMessage.NOTE_ON, root
						+ returnedNoteList.get(i), 0);
				notething = new MidiEvent(message, i);
			}
			catch (InvalidMidiDataException e)
			{
				e.printStackTrace();
			}

			midSeq.getTracks()[0].add(notething);
		}

		System.out.println(midSeq.getTracks()[0]);

		return midSeq;
	}
}
